package com.gohead.server;

import ai.platon.pulsar.common.config.ImmutableConfig;
import ai.platon.pulsar.common.config.VolatileConfig;
import ai.platon.pulsar.context.PulsarContexts;
import ai.platon.pulsar.context.support.AbstractPulsarContext;
import ai.platon.pulsar.session.AbstractPulsarSession;
import ai.platon.pulsar.session.BasicPulsarSession;
import ai.platon.pulsar.session.PulsarEnvironment;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.support.AbstractApplicationContext;

public class CrawelTst {
    public static void main(String[] args) {

        var context = PulsarContexts.create("classpath:pulsar-beans/app-context.xml");
        var session = context.createSession();

        var portalUrl = "https://list.jd.com/list.html?cat=652,12345,12349";
        var pages = session.submitForOutPages(portalUrl, "-expires 1s -itemExpires 7d -outLink a[href~=item]");
        System.out.println(pages);

        PulsarContexts.await();
    }
    public static class  CrawelContext extends AbstractPulsarContext{

        public CrawelContext(@NotNull AbstractApplicationContext applicationContext, @NotNull PulsarEnvironment pulsarEnvironment) {
            super(applicationContext, pulsarEnvironment);
        }

        @NotNull
        @Override
        public AbstractPulsarSession createSession() {
            BasicPulsarSession session = new BasicPulsarSession(this, new VolatileConfig(),10);
            return session;
        }
    }
}
